void main() {
    // 准备购物车数据
  List carts = [
    {"count": 2, "price": 10.0, "selected": true},
    {"count": 1, "price": 30.0, "selected": false},
    {"count": 5, "price": 20.0, "selected": true}
  ];

  // 调用封装的函数
  bool isSelectedAll = getSelectedState(carts);
  if (isSelectedAll) {
    print('全选');
  } else {
    print('非全选');
  }
}

// 核心逻辑：只要有任何一个商品是未勾选的，那么就是非全选
bool getSelectedState(List carts) {
  // 购物车初始的状态：假设默认是全选
  bool isSelectedAll = true;

  carts.forEach((element) {
    bool selected = element['selected'];
    // 核心代码：只要有任何一个商品是非勾选的，则购物车就是非全选
    if (selected == false) {
      isSelectedAll = selected;
    }
  });
    // 返回是否全选结果
  return isSelectedAll;
}